package com.molichuxing.services.infrastructure.service.impl;

import com.molichuxing.services.infrastructure.bean.AccidentCaseBean;
import com.molichuxing.services.infrastructure.convertor.Convert;
import com.molichuxing.services.infrastructure.dao.AccidentCaseMapper;
import com.molichuxing.services.infrastructure.dao.AccidentDriveMapper;
import com.molichuxing.services.infrastructure.dao.AccidentImageMapper;
import com.molichuxing.services.infrastructure.dto.request.create.AccidentDriveCreateDto;
import com.molichuxing.services.infrastructure.dto.response.AccidentCaseDto;
import com.molichuxing.services.infrastructure.dto.response.AccidentDriveDto;
import com.molichuxing.services.infrastructure.service.AccidentCaseService;
import com.molichuxing.services.infrastructure.service.AccidentDriveService;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;


/**
 * <p>
 * 驾驶人 服务实现类
 * </p>
 *
 * @author
 * @since 2019-08-15
 */
@Service("accidentDriveService")
public class AccidentDriveServiceImpl implements AccidentDriveService {

  private static final Logger log = Logger.getLogger(AccidentDriveServiceImpl.class);

  @Resource
  private AccidentDriveMapper accidentDriveMapper;


    @Override
    public AccidentDriveDto getCarAccidentDrive(Integer accidentId) {
        return Convert.toAccidentDriveDto(accidentDriveMapper.getById(accidentId));
    }

  @Override
  public Boolean createAccidentDrive(AccidentDriveCreateDto accidentDriveCreateDto) {
    int result = accidentDriveMapper.createAccidentDrive(Convert.toAccidentDriveBean(accidentDriveCreateDto));
    if(result > 0) {
      return true;
    }
    return false;
  }

  @Override
  public int updateAccidentDriveById(AccidentDriveCreateDto accidentDriveCreateDto) {
    return accidentDriveMapper.updateAccidentDriveById(Convert.toAccidentDriveBean(accidentDriveCreateDto));
  }
}
